/**
https://github.com/go-xorm/xorm/blob/master/README_CN.md
*/
package main

import (
	// "errors"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
)

type Users struct {
	Id   int64  `json:"id" xorm:"int pk autoincr"`
	Name string `json:"name" xorm:"varchar(255) notnull"`
}

var Db *xorm.Engine

func main() {
	Db, err := xorm.NewEngine("mysql", "root:root@tcp(127.0.0.1:3306)/test?charset=utf8&allowNativePasswords=true")
	if err != nil {
		fmt.Println(err)
	}

	// if err := Db.Sync2(new(Users)); err != nil {
	// 	fmt.Println(err)
	// }

	var users = make([]Users, 0)
	err = Db.Limit(10, 0).Find(&users)
	fmt.Println(err)
	fmt.Println(users)
}
